<?php

  session_start();
  $username = $_SESSION['username'];
  
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
    <script  src = '../js/jquery1.7.2.min.js'></script>
    <style>

    table{
            border: solid 0px gray;
            border-collapse: collapse;
            margin: auto;
        }
    </style>
</head>
<body>
    <form action="/articles-demo1-php/php/user_edit.php" id="form" method="post" enctype="multipart/form-data">
        <table>
            <tr>
                <td>用户名：</td>
                <td>
                    <input type="text" name="username" readonly value="<?=$username?>">
                </td>
            </tr>
            <tr>
            <td>新密码：</td>
            <td>
                <input type="password" name="passwd"  >
            </td>
        </tr>
        <tr>
        <td>手机</td>
        <td>
            <input type="text" id="cellphone" name="cellphone">
        </td>
        </tr>
        <tr>
        <td>头像：</td>
        <td>
            <input type="file" name="photo" >
        </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" value="提交" onclick="doEdit()">
            </td>
        </tr>
        </table>
    </form>
</body>
<script>
    function doEdit(){

       var fm = document.getElementById("form");
       var cellphone =  document.getElementById("cellphone").value;
       //https://zhuanlan.zhihu.com/p/624027494
       //验证手机号码
       var reg = /^1[3|7|8|9][0-9]{9}$/;
       var flag = reg.test(cellphone);
       if(!flag){
         alert('手机号码不符合规则');
         return false;
       }
       fm.submit();

    }
</script>

</html>